$(function(){
	//轮播图
	var $list = $(".picUl");
	var $picLi = $(".picUl li");
	var $btnLi = $(".lubonum li");
	var $backli = $(".backLi li");
	var $back = $(".backLi")
	var $wrap = $(".slide_show");

	var iNow = 0;
	var iW = $picLi.outerWidth();
	var iww = $backli.outerWidth();

	var len = $picLi.length;
	var timer = null;
	$picLi.eq(0).clone().appendTo($list);

	timer = setInterval(autoPlay,2000)
	//按钮点击切换
	$btnLi.click(function(){
		iNow=$(this).index();
		changeView()
	})
			
	//切换图片
	function changeView(){
		animated=false;
		$list.stop().animate({"left":-iNow*iW},function(){
		    animated=true;
		    if(iNow>=len){
		        $list.css("left","0px");
		    }
	})

	$back.stop().animate({"left":-iNow*iww},function(){		        	
	    animated=true;
	    if(iNow>=len){
	        $back.css("left","0px");
	    }})
		// $back.css({"left":-iNow*iww});
		$btnLi.removeClass('active').eq(iNow%len).addClass('active');
	}
	//自动轮播
	function autoPlay(){
		if(iNow>=len){
		   iNow=0;
		   $list.css({"left":0})
		   $back.css("left","0px");
		}
		iNow++;
		changeView()
	}
	//鼠标滑过清除计时器
	$wrap.hover(function(){
		if (timer) {
			clearInterval(timer);
		} 
	},function(){
		timer=setInterval(autoPlay,2000)
	})
})


